Imports System.IO

Public Class LogWriter
    Public LogOutputPath As String = ".\"
    Dim SubLogContents As String = ""

    Sub LogLine()
        System.Console.WriteLine()
        SubLogContents = SubLogContents + "<br>"
    End Sub

    Sub LogLine(ByVal Text As String)
        ' Append the log.
        Log(Text)
        System.Console.WriteLine()

        SubLogContents = SubLogContents + "<br>"
    End Sub

    Sub Log(ByVal Text As String)
        System.Console.Write(Text)

        ' Append the log.
        SubLogContents = SubLogContents + Replace(Text, Chr(10), Chr(10) + "<br>")
    End Sub

    Sub DumpLog()
        SubLogContents = ""
    End Sub

    Sub Write(ByVal LogFilename As String)
        Dim AbsFile As String
        Dim ErrInfo As String

        If Not LogFilename = Nothing Then
            AbsFile = LogOutputPath + LogFilename
            SaveTextToFile(SubLogContents, AbsFile, ErrInfo)
        End If

    End Sub

    Public Function SaveTextToFile(ByVal strData As String, _
     ByVal FullPath As String, _
       Optional ByVal ErrInfo As String = "") As Boolean

        Dim Contents As String
        Dim bAns As Boolean = False
        Dim objReader As StreamWriter
        Try


            objReader = New StreamWriter(FullPath)
            objReader.Write(strData)
            objReader.Close()
            bAns = True
        Catch Ex As Exception
            ErrInfo = Ex.Message

        End Try
        Return bAns
    End Function
End Class
